#cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.19)
project(MySharedLib VERSION 1.0)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)

# 添加动态库目标
add_library(MyShared SHARED 
    source/mylib.cpp
)

# 设置库版本号（Linux有效）
set_target_properties(MyShared PROPERTIES
    VERSION ${PROJECT_VERSION}
    SOVERSION 1
    # POSITION_INDEPENDENT_CODE ON  # 强制生成与位置无关的代码
)

# 公开头文件目录
target_include_directories(MyShared PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)

# 安装规则（可选）
install(TARGETS MyShared LIBRARY DESTINATION lib)
install(FILES include/mylib.h DESTINATION include)
